<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css"
          integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>

    <title>登录</title>
    <style>
        * {
            margin: 0%;
            padding: 0%;
        }

        html {
            height: 100%;
        }

        body {
            height: 100%;
            background-image: url("./images/login_backdrop.gif");
            background-repeat: repeat;
        }

        .login-wrapper {
            width: 540px;
            height: 260px;
            background-color: rgb(255, 255, 255, 0.4);
            transform: translate(60%, 100%);
            border-radius: 15px;
            position: relative;
        }

        .login-header {
            text-align: center;
            height: 75px;
        }

        .username {
            height: 40px;
            text-align: center;
            font-size: 18px;
        }

        .password {
            height: 40px;
            text-align: center;
            font-size: 18px;
        }

        .btn {
            width: 95px;
            height: 48px;
            text-align: center;
            font-size: 14px;
            border-radius: 5px;
            background-color: rgb(176, 224, 230);
            transform: translate(255%, 10%);
        }
    </style>
</head>
<body>
<div class="container">
    <div class="login-wrapper">
        <div class="login-header">
            <h1>登录</h1>
        </div>
        <form action="#" method="get">
            <div class="username">
                账号：<input type="text" id="username" value="18321584034">
            </div>
            <div class="password">
                密码：<input type="password" id="password" value="111111">
            </div>
        </form>
        <div class="login-button">
            <button type="button" class="btn btn-primary" id="login_btn">登录</button>
        </div>
    </div>
</div>
</body>
<script>

    $(function () {
        $("#login_btn").click(function () {

            let username = $("#username").val();
            let password = $("#password").val();
            console.log("username:", username, "password:", password)

            $.ajax({
                type: "POST",
                url: "login",
                data: {
                    phoneNumber: username,
                    password: password
                },
                //contentType: 'application/json;charset=utf-8',
                dataType: "json",
                success: function (response) {
                    console.log("登录结果!!", response)
                    if (response.code == "200") {
                        window.location.href = "goToGoodsList";
                    } else {
                        alert(response.msg)
                    }
                }
            });
        })
    })

</script>
</html>